  {extend name="Public:base" /}
  {block name="css"}

  {/block}
  {block name="extenddiv"}

  {/block}
    {block name="extenddivend"}

  {/block}
  {block name="body"}
  <form class="form-horizontal" data-url="{:url('doc/docuploadinfo')}" id="docuploadform">
<div id="upload-init-container " class="container upload-widget" style="display: block;">
<div class="upload-hd-2017">
<div class="upload-hd"></div>
<div class="upload-steps clearfix">
<ul>
<li class="step-num  active">1<span class="tips">选择文档</span>
</li>
<li class="step-bar  active"></li>
<li class="step-num  active">2<span class="tips">完善信息</span>
</li>
<li class="step-bar"></li>
<li class="step-num">3<span class="tips">完成上传</span>
</li>
</ul>
</div>
</div>
<div class="es-panel  " style="margin-bottom:60px;">
<div class="uploadinfo">

<div class="uploadinfo-content ">
<div class="form-group  col-sm-8">
    <label for="title" class="col-sm-3  control-label"><span class="text-danger">*</span>标题:</label>
   <div class="col-sm-7">
      <input type="text" name="title"  class="form-control" id="title" placeholder="请输入文档标题">
  <span id="helpBlock" class="help-block ">建议您结合文档正文完善文档标题信息，标题中请勿含标点符号</span>
  </div>
  </div>
  <div class="form-group  col-sm-8">
    <label for="score" class="col-sm-3 control-label">售价:</label>
    <div class="col-sm-5">
    <select class="form-control" name="score"  id="score">
  <option value="0">免{$pointname}</option>
  <option value="1">1{$pointname}</option>
  <option value="2">2{$pointname}</option>
 <option value="5">5{$pointname}</option>
  <option value="8">8{$pointname}</option>
  <option value="10">10{$pointname}</option>
  <option value="20">20{$pointname}</option>
</select>
     </div> 
  </div>
  
  <div class="clearfix"></div>
</div>
<div class="uploadinfo-content-end ">

<div class="form-group col-sm-8">
    <label for="tid" class="col-sm-3  control-label"><span class="text-danger">*</span>分类:</label>
   
   <div class="row">
      <div class="col-sm-4" style="padding-right:0px;" >
       <select class="form-control "  id="groupcateid" name="gid" size="10" style="overflow-y:auto" >
       {volist name="groupcatelist" id="vo"}
       <option value="{$vo.id}">{$vo.name}</option>
       {/volist}
 
</select>
  </div>
   <div class="col-sm-4" style="">
<select class="form-control" name="tid" id="tid"   size="10"  style="overflow-y:auto" >
 
 
    
</select>
  </div>
   
   </div>

  </div>
  
    {if condition="$xsid eq 0"}
  <div class="form-group  col-sm-8">
    <label for="status" class="col-sm-3  control-label">类型:</label>
    <div class="col-sm-6">
    <label class="checkbox-inline" style="padding-top:5px;">
  <input type="checkbox" id="status" name="status"  value="2"> 私有文档
</label>
</div>
</div>
{/if}


  <div class="clearfix"></div>
<div class="form-group  col-sm-8">
    <label for="keywords" class="col-sm-3 control-label">标签:</label>
    <div class="col-sm-8">
    
    <input type="hidden" name="keywords" value="">
   
    <div class="clearfix"></div>
    <div class="biaoqian">
     <div id="tpt_sel" class="tpt_sels" >
    <span style="margin-bottom: 5px;float: left;">
			</span>
    </div>
    <input type="text" class="" id="tpt_input"  placeholder="点击此处填写标签" >
    </div>
    
    
      
      <button class="btn btn-default es-margin-t-10" id="tpt_btn" type="button" >添加标签</button>
</div>
  </div>
    <div class="clearfix"></div>
  <div class="form-group    col-sm-8 " style="padding-left: 0px;">
  
  
  
  
        <div id="tpt_pre" class="col-sm-offset-4  keyword-sug-wrap tpt_pres" style="display: block;">
       
        <p class="es-padding-t-10">
        {volist name="taglist" id="vo"}
        <span class="item-tag"><a href="javascript:;">{$vo}</a></span>
        {/volist}
        
        </p></div>
  
  </div>
  
    <div class="form-group  col-sm-8">
    <label for="description" class="col-sm-3 control-label">简介:</label>
    <div class="col-sm-7">
      <textarea rows="4"  class="form-control" name="description" id="description" placeholder="填写文档简介"></textarea>
    </div>
  </div>

</div>

        <input type="hidden" name="xsid"  class="form-control" id="xsid" value="{$xsid}">
  
 

</div>

</div>
 <div class="edit-all-head ">
 <div class="container ">
  <div class="col-sm-4"></div>
 <div class="col-sm-8 text-right" style="padding:0px;">
 <span class="item-message-all-subtitle col-sm-8">审核通过后，您将获得<span class="item-reward-wealth">{$point_tip}</span>的奖励</span>
<div style="padding:0px;" class="col-sm-4">
<button type="button" class="btn btn-warning uploadinfoajax"><i class="iconfont icon-duigou"></i> 确认上传</button></div>
</div>
</div>
  </div>
</div>
</form>
  {/block}
  {block  name="extenddivend"}
  <script>

  $(function(){
	  
		$('#tpt_input').keydown(function(e) {
			if (e.which === 13) {
				$("#tpt_btn").click();
				e.preventDefault();
				return false;
			}
		});
		$("#tpt_sel").on('click', 'a>i', function() {
			var name = "keywords";
			var tag = $(this).parent().text();
			$(this).parent().remove();
			var tags = new Array();
			$("#tpt_sel").find('a').each(function() {
				tags.push($(this).text());
			});
			$("input[name=" + name + "]").val(tags.join(","));
			$("#tpt_pre a:contains('" + tag + "')").removeClass("selected");
		});
		$("#tpt_btn").click(function() {
			var name = "keywords";
			var tags = $.trim($("input[name=" + name + "]").val());
			if (tags !== "") {
				tags = tags.split(",");
			} else {
				tags = new Array();
			}
			var tag = $.trim($("#tpt_input").val());
			if (tag !== '' && $.inArray(tag, tags) === -1) {
				tags.push(tag);
				$("#tpt_pre a:contains('" + tag + "')").addClass("selected");
			}
			$("#tpt_sel").children('span').empty();
			$.each(tags, function(k, v) {
				$("#tpt_sel").children('span').append('<a href="javascript:;">' + v + '<i class="fa fa-times"></i></a>');
			});
			$("input[name=" + name + "]").val(tags.join(","));
			$("#tpt_input").val('');
		});
		$("#tpt_pre").on('click', 'a:not(.selected)', function() {
			var name = "keywords";
			var tags = $.trim($("input[name=" + name + "]").val());
			if (tags !== "") {
				tags = tags.split(",");
			} else {
				tags = new Array();
			}
			var tag = $.trim($(this).text());
			if (tag !== '' && $.inArray(tag, tags) === -1) {
				tags.push(tag);
			}
			$("#tpt_sel").children('span').empty();
			$.each(tags, function(k, v) {
				$("#tpt_sel").children('span').append('<a href="javascript:;">' + v + '<i class="fa fa-times"></i></a>');
			});
			$("input[name=" + name + "]").val(tags.join(","));
			$(this).addClass('selected');
		});
	  
	  
	  
	  $('#groupcateid').change(function(){
		  
		  $.post("{:url('Doc/getDoccatedata')}",{id:$(this).val()},function(data){
			  $('#tid').html('');
			 
			  for(var i=0;i<data.length;i++){
				  
				  $('#tid').append('<option value="'+data[i]['id']+'">'+data[i]['name']+'</option>');
				  
			  }
			  
			 
			  
		  });
		  
	  });
	  
	var sessionid="{:session('last_uploadid')}";
	  

			  if(sessionid>0){
				  
				  $.post("{:url('File/getFileInfo')}",{id:sessionid},function(data){
					   
					  $('#title').val(data.name);
					  
				  });
				  
				  
				  
				  
				  $('.uploadinfoajax').click(function(){
					  
					  loading = layer.load(2, {
					      shade: [0.2,'#000']
					    });
					
					  $.post($('form#docuploadform').data('url'),$('form#docuploadform').serialize(),function(data){
				    	
				      if(data.code == 1){
				        layer.close(loading);
				        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
				          location.href="{:url('Doc/docuploadcomplete')}";
				        });
				      }else{
				        layer.close(loading);
				        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
				        
				       
				        
				      }
				    });
				    return false;
				    
				  });
				  
				  
				  
				  
			  }else{
					layer.msg('文档上传出错请重新上传', {icon: 2, time: 1000}, function(){
						 location.href="{:url('Doc/docupload')}";
			        });
				 
			  }
		

	  
	  
	  
  });
  </script>

    {/block}